package com.github.ikidou.cqj;

import com.github.ikidou.entity.BaseEntity;
import com.github.ikidou.entity.MachineCoupon;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by jon on 17-9-24.
 * accesstoken=C9063D76949B438A8361FC7EBD330D0D&os=Android&version=1000000&status=0&start=0&limit=10
 */

public class Test3 {
    public static void main(String[] args) {

        Gson gson = new GsonBuilder().create();
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(Contanst.cqjUrl)
                .addConverterFactory(GsonConverterFactory.create(gson))
                .build();

        Map<String, String> map = new HashMap<>();
        map.put("accesstoken", "3332747F9EF94942B84E1DF6327265DA");
        map.put("os", "Android");
        map.put("version", "1000000");
        map.put("status", "0");
        map.put("limit", "10");
        map.put("start", "0");
        Call<BaseEntity<List<MachineCoupon>>> call = retrofit.create(ApiServcie.class).postConvertCoupon(map);
        call.enqueue(new Callback<BaseEntity<List<MachineCoupon>>>() {

            @Override
            public void onResponse(Call<BaseEntity<List<MachineCoupon>>> call, Response<BaseEntity<List<MachineCoupon>>> response) {
                System.out.println(response.body());
            }

            @Override
            public void onFailure(Call<BaseEntity<List<MachineCoupon>>> call, Throwable t) {

            }
        });

    }
}
